
// export const DEFAULT_VALUE = {
//   ARRAY: '[]',
//   OBJECT: '{}',
//   STRING: '',
// }

// interface ILocalStorageFactoryParams<T> { 
//   key:string,
//   defaultValue:string,
//   raw?:boolean,
//   serializer:(value : T)=>{}
//   deserializer?: (value: string) => T
// }

// interface ILocalStorageFactoryReturn<T>{
//   setItem:(value:T)=> void
//   getItem:()=> T
//   removeItem:()=> void
// }

// export const LocalStorageFactory = <T>(params:ILocalStorageFactoryParams<T>):ILocalStorageFactoryReturn<T>=>{
//   const  {key,defaultValue,raw,serializer = JSON.stringify,deserializer = JSON.parse} =  params

//   const setItem = (value:T)=>{
//     //类型断言
//     const data = (raw ? value : serializer(value)) as string
//     localStorage.setItem(key,data || defaultValue)
//   }

//   const  getItem = ()=>{
//     const data = localStorage.getItem(key) || defaultValue
//     return raw ? data:deserializer(data)
//   }

//   const removeItem = ()=> localStorage.removeItem

//   return {
//     setItem,
//     getItem,
//     removeItem,
//   }

// }


import {DEFAULT_VALUE , localStorageFactory}  from './localStorage'
import {ILoginResult } from 'apis/types/auth'

const KEY = '_session'

export const sessionLocalStorage =   localStorageFactory<ILoginResult>({
  key: KEY,
  defaultValue:DEFAULT_VALUE.OBJECT
}) 
